import 'dart:async';

import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/cupertino.dart';
import 'package:school_safe_teacher/constans/constants.dart';
import 'package:school_safe_teacher/resourse/app_colors.dart';

class LoginState implements Cloneable<LoginState> {
  String loginWay;
  int loginWayType; //0 验证码登录，1 手机号密码登录
  String phoneImg;
  String pwdImg;
  String pwdCanSeeImg;
  String checkResource;
  bool checked;

  String mobile;
  String pwd;
  String code;

  Color loginTextColor;
  Color loginBtnStartColor;
  Color loginBtnEndColor;

  bool showPwd;

  int countdownTime;
  String countdownString;
  Timer countdownTimer;

  Color textColor;

  @override
  LoginState clone() {
    return LoginState()
      ..loginWay = loginWay
      ..loginWayType = loginWayType
      ..phoneImg = phoneImg
      ..pwdImg = pwdImg
      ..pwdCanSeeImg = pwdCanSeeImg
      ..checkResource = checkResource
      ..checked = checked
      ..mobile = mobile
      ..pwd = pwd
      ..code = code
      ..loginTextColor = loginTextColor
      ..loginBtnStartColor = loginBtnStartColor
      ..loginBtnEndColor = loginBtnEndColor
      ..showPwd = showPwd
      ..textColor = textColor
      ..countdownTimer = countdownTimer
      ..countdownTime = countdownTime
      ..countdownString = countdownString;
  }
}

LoginState initState(Map<String, dynamic> args) {
  var state = LoginState()
    ..loginWay = "密码登录"
    ..loginWayType = Constants.LOGIN_PWD_WAY
    ..phoneImg = "images/phone_icon_unselect@2x.png"
    ..pwdImg = "images/pwd_icon_unselect@2x.png"
    ..pwdCanSeeImg = "images/pwd_cannot_see@2x.png"
    ..checked = false
    ..mobile = ""
    ..pwd = ""
    ..code = ""
    ..loginTextColor = AppColors.cantClickTextColor
    ..loginBtnStartColor = AppColors.loginBtnColor
    ..loginBtnEndColor = AppColors.loginBtnColor
    ..showPwd = true;
  if (!state.checked) {
    state..checkResource = "images/server_check@2x.png";
  } else {
    state..checkResource = "images/server_not_check@2x.png";
  }
  return state
    ..textColor = AppColors.loginLeft
    ..countdownTime = 0
    ..countdownString = "发送验证码";
}
